import 'package:flutter/material.dart';
import 'package:flutter_baidu_map/loc/loc_map_page.dart';
import 'package:flutter_baidu_map/loc/loc_page.dart';
import 'package:flutter_baidu_map/loc/map_page.dart';

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);
    
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  int _selectedIndex = 0;
  final _pages = [LocPage(),LocMapPage(),MapPage() ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("百度地图"),
      ),

      bottomNavigationBar: BottomNavigationBar(
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(title: Text('定位'),icon: Icon(Icons.location_on)),
          BottomNavigationBarItem(title: Text('...'),icon: Icon(Icons.radio_button_unchecked)),
          BottomNavigationBarItem(title: Text('地图'),icon: Icon(Icons.map)),
        ],
        currentIndex: _selectedIndex,
        fixedColor: Colors.blue,
        onTap: _onItemTapped,
      ),
      body: _pages[_selectedIndex],
    );
  }

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }
}
